//
//  RNEventDispacher.swift
//  app_rn_frontend
//
//  Created by 鱼涛 on 2017/12/12.
//  Copyright © 2017年 Facebook. All rights reserved.
//

import UIKit
import SwiftHash

@objc class EventProcessorWrapper: NSObject {

    @objc func process(eventName: String, params: Dictionary<String, Any>?) {
        DispatchQueue.global().async {
            do {
                let now = Date()
                let df = DateFormatter()
                df.dateFormat = "yyyy-MM-dd HH:mm:ss.sss"

                print("********** EVENT INFO **********")
                print("[\(Thread.current.name)]--firedTime: \(df.string(from: now))")
                print("eventName: \(eventName)")
                print("params: \(params)")
                try EventProcessorFactory.instance.getProcessor(eventName: eventName).process(params: params)
                print("\(eventName) normal end********************************")
            } catch let err as NSError {
                print(err.localizedDescription)
                print("\(eventName) error end********************************")
            }
        }

    }

}
